package com.wash.car.web.controller.admin;

import com.github.pagehelper.PageInfo;
import com.pmo.boot.common.api.BaseResult;
import com.pmo.boot.common.api.DefaultResult;
import com.wash.car.biz.StoreServer;
import com.wash.car.dao.model.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = {"门店管理"})
@RestController
@RequestMapping(path = "/admin/store")
public class AdminStoreController {

    @Autowired
    private StoreServer storeServer;

    @ApiOperation(value = "添加门店")
    @PostMapping(path = "add")
    public BaseResult add(@RequestBody StoreAddModel model) {
        storeServer.add(model);
        return BaseResult.success();
    }

    @ApiOperation(value = "修改门店")
    @PostMapping(path = "edit")
    public BaseResult edit(@RequestBody StoreEditModel model) {
        storeServer.edit(model);
        return BaseResult.success();
    }

    @ApiOperation(value = "删除门店")
    @PostMapping(path = "del")
    public BaseResult del(@RequestBody StoreDeleteModel model) {
        storeServer.del(model);
        return BaseResult.success();
    }


    @ApiOperation(value = "门店管理")
    @GetMapping(path = "page")
    public DefaultResult<PageInfo<StorePageModel>> page(StorePageWhereModel vo) {
        PageInfo<StorePageModel> pageInfo = storeServer.page(vo);
        return DefaultResult.success(pageInfo);
    }

}
